package org.example;

public class Test1 {
    //leetcode 无重复字符的最长子串
    // https://leetcode.cn/problems/longest-substring-without-repeating-characters/description/?envType=study-plan-v2&envId=top-interview-150
    public int lengthOfLongestSubstring(String s) {
        int[] hash = new int[128];
        int ret = 1, n = s.length(), left = 0, right = 0;
        if (n == 0 || n == 1) return n;
        while (right < n) {
            while (right < n && hash[s.charAt(right)] == 0) {
                hash[s.charAt(right)] = 1;
                right++;
            }
            ret = Math.max(ret,right-left);
            while (right < n && left < right && s.charAt(left) != s.charAt(right)) {
                hash[s.charAt(left)] = 0;
                left++;
            }
            left++;
            right++;
        }
        return ret;
    }

    public static void main(String[] args) {
        Test1 test1 = new Test1();
        test1.lengthOfLongestSubstring("abcabcbb");
        System.out.println(666);
    }
}
